﻿using System;
using System.Collections.Generic;
using System.Text;
using System.IO;

namespace ChronoNES
{
    abstract class Loader
    {
        protected FileStream fs;
        protected Mapper mapper;
        
        public Loader(FileStream _fs)
        {
            fs = _fs;
        }

        public abstract Mapper GetMapper();

        public static Loader Create(FileStream _fs)
        {
            byte[] magic = new byte[3];
            _fs.Read(magic, 0, 3);

            switch (Encoding.UTF8.GetString(magic))
            {
                case "NES":
                    return new Loader_NES(_fs);
                case "UNI":
                    throw new Exception("Unsupported UNIF fromat");
            }

            throw new Exception("Unkown file format");
        }
    }
}
